package pt.inescid.components.policyengine.heimdall.contact;

import java.io.Serializable;
import java.util.Vector;

public class RemoteResponse implements Serializable {
	
	public static final String[] RESPONSE_NAMES = {
		"Undefined",
		"Ok",
		"Unknown User",
		"Query Ces Response",
		"Test Response",
		"Unknown CES",
		"Unknown Policy",
		"Remote Evaluation Response"
	};
	
	public static final int UNDEFINED_RESPONSE = 0;
	public static final int OK_RESPONSE = 1;
	public static final int UNKNOWN_USER_RESPONSE = 2;
	public static final int QUERY_CES_RESPONSE = 3;
	public static final int TEST_RESPONSE = 4;
	public static final int UNKNOWN_CES_RESPONSE = 5;
	public static final int UNKNOWN_POLICY_RESPONSE = 6;
	public static final int REMOTE_EVALUATION_RESPONSE = 7;
	
	private int type = UNDEFINED_RESPONSE;
	private String hostname = null;
	private int hostport;
	private Vector message = null;
	
	
	public RemoteResponse() {
		this (UNDEFINED_RESPONSE, null);
	}

	public RemoteResponse(int type, Vector message) {
		super();
		// TODO Auto-generated constructor stub
		this.type = type;
		this.message = message;
	}


	public Vector getMessage() {
		return message;
	}


	public int getType() {
		return type;
	}


	public void setMessage(Vector message) {
		this.message = message;
	}


	public void setType(int type) {
		this.type = type;
	}
	
	public String toString() {
		String result = RESPONSE_NAMES[type];
		
		if (message != null) {
			for (int i = 0; i < message.size(); i++) {
				result += " " + message.elementAt(i).toString();
			}
		}
		return (result);
	}

	public String getHostname() {
		return hostname;
	}

	public int getHostport() {
		return hostport;
	}

	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	public void setHostport(int hostport) {
		this.hostport = hostport;
	}
	
	public void addParameter(Object newParam) {
		if (message == null) {
			message = new Vector();
		}
		this.message.add(newParam);
	}
	

}; // RemoteResponse
